package com.jzg.jcptadmin.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import com.jzg.jcptadmin.R;
import com.jzg.jcptadmin.adpter.CarDiffListAdapter;
import com.jzg.jcptadmin.base.BaseActivity;
import com.jzg.jcptadmin.data.vo.CarTypeSelectModel;

import java.io.Serializable;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
/**
 * 备选车型
 * @time 2017/3/20 9:54
 * @author libo
 */
public class CarDifferenceActivity extends BaseActivity {

    @Bind(R.id.title_content)
    TextView tvTitle;
    @Bind(R.id.lvCarList)
    ListView lvCarList;
    private CarDiffListAdapter carDiffListAdapter;
    private List<CarTypeSelectModel.DataBean.ListBeanX.ListBean> datas;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_car_diff);
        ButterKnife.bind(this);
        tvTitle.setText("备选车型");
        datas = (List<CarTypeSelectModel.DataBean.ListBeanX.ListBean>) getIntent().getSerializableExtra("data");

        carDiffListAdapter = new CarDiffListAdapter(this,datas);
        lvCarList.setAdapter(carDiffListAdapter);

        lvCarList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent();
                intent.putExtra("ListDataBean", (Serializable) datas.get(position));
                setResult(RESULT_OK,intent);
                finish();
            }
        });
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        ButterKnife.unbind(this);
    }
}
